package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.BookCoinRewardAcctHistory;
import com.pgybook.db.entity.domain.BookCoinRewardAcctHistoryEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface BookCoinRewardAcctHistoryMapper {
    int countByExample(BookCoinRewardAcctHistoryEx example);

    int deleteByExample(BookCoinRewardAcctHistoryEx example);

    @Delete({
            "delete from bookcoinrewardaccthistory",
            "where COINREWARDHISID = #{coinrewardhisid,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long coinrewardhisid);

    @Insert({
            "insert into bookcoinrewardaccthistory (CUSTID, TYPE, ",
            "ORDERID, INSTANCEID, ",
            "AMOUNT, CRTTIME)",
            "values (#{custid,jdbcType=BIGINT}, #{type,jdbcType=INTEGER}, ",
            "#{orderid,jdbcType=BIGINT}, #{instanceid,jdbcType=BIGINT}, ",
            "#{amount,jdbcType=DECIMAL}, #{crttime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "coinrewardhisid", before = false, resultType = Long.class)
    int insert(BookCoinRewardAcctHistory record);

    int insertSelective(BookCoinRewardAcctHistory record);

    List<BookCoinRewardAcctHistory> selectByExample(BookCoinRewardAcctHistoryEx example);

    @Select({
            "select",
            "COINREWARDHISID, CUSTID, TYPE, ORDERID, INSTANCEID, AMOUNT, CRTTIME",
            "from bookcoinrewardaccthistory",
            "where COINREWARDHISID = #{coinrewardhisid,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    BookCoinRewardAcctHistory selectByPrimaryKey(Long coinrewardhisid);

    int updateByExampleSelective(@Param("record") BookCoinRewardAcctHistory record, @Param("example") BookCoinRewardAcctHistoryEx example);

    int updateByExample(@Param("record") BookCoinRewardAcctHistory record, @Param("example") BookCoinRewardAcctHistoryEx example);

    int updateByPrimaryKeySelective(BookCoinRewardAcctHistory record);

    @Update({
            "update bookcoinrewardaccthistory",
            "set CUSTID = #{custid,jdbcType=BIGINT},",
            "TYPE = #{type,jdbcType=INTEGER},",
            "ORDERID = #{orderid,jdbcType=BIGINT},",
            "INSTANCEID = #{instanceid,jdbcType=BIGINT},",
            "AMOUNT = #{amount,jdbcType=DECIMAL},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP}",
            "where COINREWARDHISID = #{coinrewardhisid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(BookCoinRewardAcctHistory record);
}
